/**
	Audier1 - Commandline app to batch edit id3 tags in audio files
	
	Email	:	hypercas@gmail.com
	Created :	16/Feb/2011
	Modified:	19/Mar/2011
**/

#define AUDIER_VERSION "0.4"

 
#include "audier.h"
#include <tclap/CmdLine.h>

using namespace Audier;


int main(int argc,char *argv[])
{
	std::cout<<"Audier "<<AUDIER_VERSION<<", 2011";
	
	//Album Resource
	Album album;

	//Lua settings
	//fs::path file_lua;
	//file_lua = fs::system_complete("settings.lua");
	
	//Parse commandline
	try 
	{  
 
		TCLAP::CmdLine cmd("Audier", ' ', AUDIER_VERSION);
		TCLAP::ValueArg<std::string> ab_album("n","name","Album name",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_title("t","title","Album title",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_year("y","year","Album year",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_artist("a","artist","Album artist",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_genre("g","genre","Album genre",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_picture("p","picture","Album art",false,"","string", cmd);
		TCLAP::ValueArg<std::string> ab_file_ext("e","extention","Album file extention",false,".mp3","string", cmd);
		TCLAP::ValueArg<std::string> ab_track_start("s","startnumber","Track number start value",false,"","string", cmd);

		// Parse the argv array.
		cmd.parse( argc, argv );

		if( ab_album.getValue().size() )	album.SetAlbum( ab_album.getValue().c_str() );
		if( ab_title.getValue().size() )	album.SetTitle( ab_title.getValue().c_str() );
		if( ab_year.getValue().size() )		album.SetYear( ab_year.getValue().c_str() );
		if( ab_artist.getValue().size() )	album.SetArtist( ab_artist.getValue().c_str() );
		if( ab_genre.getValue().size() )	album.SetGenre( ab_genre.getValue().c_str() );

		if( ab_file_ext.getValue().size() )		album.SetFileExt( ab_file_ext.getValue().c_str() );
		if( ab_track_start.getValue().size() )	album.SetTrackStart( ab_track_start.getValue().c_str() );

		if( ab_picture.getValue().size() )	album.SetPicture( ab_picture.getValue().c_str() );
		else album.DirectoryGetPicture( boost::filesystem::current_path() );

	} 
	
	catch (TCLAP::ArgException &e)  // catch any exceptions
	{
		std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; 
	}

	
	album.DirectoryGetFiles( boost::filesystem::current_path() );
	album.FileAutoProcess();

	return 0;
}